<?php

class QaModule extends CWebModule {

	public $install = false;
	
	public $userClass = 'User';
	
	public $admins = array();

	public function init() {
		$aliases = array(
			'qa.models.*',
			'qa.components.*',
			'qa.extensions.*',
		);
		$this->setImport($aliases);
		$this->defaultController = 'question';
	}

	public function beforeControllerAction($controller, $action) {
		if (parent::beforeControllerAction($controller, $action)) {
			return true;
		}
		else return false;
	}

	public function getInstaller() {
		$components = array(
			'installer'=>array(
				'class'=>'QaInstaller',
			),
		);
		$this->setComponents($components);
		return $this->getComponent('installer');
	}

	private $_assetsUrl;

	public function getAssetsUrl() {
		if ($this->_assetsUrl === null) {
			$path = Yii::getPathOfAlias('qa.assets');
			$asset = Yii::app()->assetManager;
			if (YII_DEBUG) {
				$url = $asset->publish($path, false, -1, true);
			} else {
				$url = $asset->publish($path);
			}
			$this->_assetsUrl = $url;
		}

		return $this->_assetsUrl;
	}

}
